package com.orangecy.infrastructure.persistent.common;

import com.orangecy.common.exception.OrangeCyException;

import java.util.List;

/**
 * @Author : orangeCy.奕
 * @Product : 猎豹养成产品源码
 * @Time : 2021/10/29
 * @Desc :提取对仓储层共性操作
 */
public abstract class AbstractDAO<T> {

    /**
     * 抽象方法，获取操作表mapper
     * @return
     */
    public abstract BaseMapper<T> getMapper();

    public T findById(Long id) {
        try {
            return this.getMapper().findById(id);
        }catch (Exception ex) {
            throw new OrangeCyException("DAO-ERROR","findById查询db异常");
        }
    }

    public List<T> getListByIds(List<Long> ids) {
        try {
            return this.getMapper().getList(ids);
        } catch (Exception ex) {
            throw new OrangeCyException("DAO-ERROR", "getListByIds查询db异常");
        }
    }
}